package com.biz.primus.model.oms.vo;

import com.biz.primus.model.oms.enums.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

/**
 * @author yanweijin
 * @date 2017/10/31
 */

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@ApiModel("oms订单主体")
public class OmsOrderVo {


	@ApiModelProperty("oms收到订单的时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	LocalDateTime omsCreateTime;

	@ApiModelProperty("订单编号")
	String code;

	@ApiModelProperty(value="订单类型",allowableValues = "orders, returns")
	String type;

	@ApiModelProperty(value="特殊订单活动id", notes = "例如秒杀活动,预售活动, 当标识==normal时不需要")
	String specialEventId;

	@ApiModelProperty(value = "特殊订单标识")
	SpecialOrderMark specialOrderMark = SpecialOrderMark.normal;

//	@ApiModelProperty("支付方式,来自erp的支付编码")
//	String paymentWay;

	@ApiModelProperty("原订单号,订单拆分(split)之后,记录原始订单code,外部订单不传这个值")
	String sourceOrderCode;

	@ApiModelProperty("订单状态, 线上订单默认是begin(新订单),线下订单可以有其他状态")
	OrderState state;

	@ApiModelProperty("支付状态,如果支付状态为已支付(paid),应该将支付记录传过来(payments中)")
	OrderPaymentState paymentState;

	@ApiModelProperty("渠道编号")
	String channel;

	@ApiModelProperty(value="订单来源",allowableValues = "pos,ios,android,wechat")
	String orderSource;

	@ApiModelProperty("指定的门店编号,如果有,那么订单一定分配给该门店")
	String depot;

	@ApiModelProperty("期望的门店编号,在depot参数不存在时,通过自动分单算法没有匹配到门店,则优先使用本门店")
	String expectDepot;

	@ApiModelProperty("POS编号,线上订单为9999")
	String posNo = "9999";

	@ApiModelProperty("POS收银小票编号,线上订单为订单号")
	String invNo;

	@ApiModelProperty("已清金额(已支付金额)")
	Integer liquidated = 0;

	/**
	 * 订单金额
	 */
	@ApiModelProperty("订单金额(已经抵扣了各类优惠券/促销的金额)")
	Integer amount = 0;

	@ApiModelProperty("运费金额")
	Integer freightAmount = 0;

	@ApiModelProperty("使用的积分数")
	Integer usePoint = 0;

	@ApiModelProperty("各类优惠抵扣的金额总和")
	Integer discountAmount = 0;


	@ApiModelProperty("促销活动优惠抵扣的金额")
	Integer discountPop = 0;
	@ApiModelProperty("优惠券抵扣的金额")
	Integer discountCoupon = 0;
	@ApiModelProperty("临时优惠抵扣的金额")
	Integer discountGrant = 0;



	@ApiModelProperty("用户id")
	Long userId;

	@ApiModelProperty("用户类型,例如虚拟用户..等")
	String userType;

	@ApiModelProperty("配送方式")
	OrderDeliveryType deliveryType;

	@ApiModelProperty(value="第三方物流供应商", allowableValues = "sf,deppon")
	String expectedExpressProvider;

	@ApiModelProperty("快递单号,配送方式为third_party时需要传递这个值")
	String expressNumber;


	@ApiModelProperty("配送状态")
	OrderDeliveryState deliveryState = OrderDeliveryState.for_outbound;

	@ApiModelProperty(value="销售时间/预售时间, 格式为yyyy-MM-dd HH:mm:ss", dataType = "java.lang.String")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	LocalDateTime saleTime;

	@ApiModelProperty(value="期望收货时间, 格式为yyyy-MM-dd HH:mm:ss, 用于立即送的场合", dataType = "java.lang.String")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	LocalDateTime expectedReceivingTime;

	/**
	 * 配送时效
	 * in19m
	 * in29m
	 * in59m
	 */
	@ApiModelProperty(value = "配送时效", allowableValues = "in19m, in29m, in59m")
	String deliveryTimeliness;

	@ApiModelProperty("收货人信息")
	OmsConsigneeVo consignee;

//	@ApiModelProperty("是否需要发票")
//	boolean needInvoice;
//
//	@ApiModelProperty("发票信息")
//	OmsInvoiceVo invoice;

	@ApiModelProperty("用户备注")
	String remark;

	@ApiModelProperty("客服备注(客户不可见)")
	String selfRemark;

	@ApiModelProperty("订单项")
	List<OmsItemVo> items = Collections.emptyList();

	@ApiModelProperty("支付记录")
	List<OmsPaymentVo> payments = Collections.emptyList();

	@ApiModelProperty("用户手机号")
	String mobile;

	@ApiModelProperty("用户昵称")
	String nickname;

	@ApiModelProperty("用户级别")
	Long userLevel;

	@ApiModelProperty("订单创建人(客服坐席/pos收营员), 线上渠道没有这个参数")
	String operator;

}
